<template>
	<custom-page>
	<view>
		<view style="background-color: #fff;margin-top: 0rpx;padding: 20rpx 0;">
		  <!-- <u-cell-group :border="false">
		    <u-cell
		        icon="bell-fill"
		        size="large"
		        title="通知公告"
		        :titleStyle="{'font-size':'50rpx'}"
		        :iconStyle="{'font-size':'50rpx'}"
		        :rightIconStyle="{'font-size':'40rpx'}"
		        isLink
		        :border="false"
		    ></u-cell>
		  </u-cell-group> -->
		
		  <view style="display: flex;justify-content: space-between;padding: 20rpx 20rpx;margin-top: 40rpx;" v-for="(item,index) in messageList" :key="index" @click="detail" :id="item.id">
		    <view style="padding: 0 20rpx;">
		      <view style="font-size: 30rpx;font-weight: 700;">{{item.title}}</view>
		      <view style="font-size: 30rpx;color: #ccc;">{{item.Subtitle}}</view>
		      <view style="display: flex;justify-content: space-between;margin-top: 20rpx;">
		        <u-tag text="通知" type="error" size="mini" plain plainFill></u-tag>
		        <view style="font-size: 28rpx;color: #ccc;">{{item.create_time}}</view>
		      </view>
		    </view>
		    <view>
		     <u-image
		          radius="20"
		          :src="item.image"
		          shape="square" width="260" height="200"
						v-if="item.image != ''"
		      ></u-image>
		    </view>
		  </view>
		
		  <!-- <view style="display: flex;justify-content: space-between;padding: 20rpx 20rpx;margin-top: 20rpx;">
		    <view style="padding: 0 20rpx;">
		      <view style="font-size: 30rpx;font-weight: 700;">关于电梯维修和保养的通知</view>
		      <view style="font-size: 30rpx;color: #ccc;">尊敬的住户：A栋电梯将在早上10点进行维护</view>
		      <view style="display: flex;justify-content: space-between;margin-top: 20rpx;">
		        <u-tag text="通知" type="error" size="mini" plain plainFill></u-tag>
		        <view style="font-size: 28rpx;color: #ccc;">2022-4-30</view>
		      </view>
		    </view>
		    <view>
		      <u-image
		          radius="20"
		          src="https://img0.baidu.com/it/u=3973107883,39934522&fm=253&fmt=auto&app=138&f=JPEG?w=780&h=390"
		          shape="square" width="260" height="200"
		      ></u-image>
		    </view>
		  </view>
		
		  <view style="display: flex;justify-content: space-between;padding: 20rpx 20rpx;margin-top: 20rpx;">
		    <view style="padding: 0 20rpx;">
		      <view style="font-size: 30rpx;font-weight: 700;">关于电梯维修和保养的通知</view>
		      <view style="font-size: 30rpx;color: #ccc;">尊敬的住户：B栋电梯将在早上10点进行维护</view>
		      <view style="display: flex;justify-content: space-between;margin-top: 20rpx;">
		        <u-tag text="通知" type="error" size="mini" plain plainFill></u-tag>
		        <view style="font-size: 28rpx;color: #ccc;">2022-4-30</view>
		      </view>
		    </view>
		    <view>
		      <u-image
		          radius="20"
		          src="https://img0.baidu.com/it/u=3973107883,39934522&fm=253&fmt=auto&app=138&f=JPEG?w=780&h=390"
		          shape="square" width="260" height="200"
		      ></u-image>
		    </view>
		  </view> -->
		
		
		</view>
	</view>
	</custom-page>
	
</template>
<script>
	import Api from '@/util/api.js'
	export default {
		data() {
			return {
				messageList:{}
			};
		},
		onLoad(e) {
			var that = this
			that.checkUser()
			that.MessageList();
			
		},
		methods:{
			// 检查用户信息
			checkUser(){
				var that  = this
				var userInfo = that.userInfo;
				// if(userInfo == ''){
					if(localStorage.getItem('userInfo')){
						that.userInfo = JSON.parse(localStorage.getItem('userInfo'))
					}else{
						// uni.showToast({
						//     icon: 'none',   
						//     duration: 3000,
						//     title: "当前用户未登录"
						// });
						return;
					}
				// }
				
			},
			MessageList(){
				var that = this
				var data = {
					user_id : that.userInfo.id
				}
				
				Api.getMessage(data).then(res=>{
					console.log('获取成功',res)
					that.messageList = res.data
				})
			},
			detail(current){
				console.log('点击了',current.currentTarget.id)
				uni.navigateTo({
					// url:'./detail?id='+current.currentTarget.id
					url:'/pages/index/detail?id='+current.currentTarget.id + '&type=message'
				})
			}
		}
	}
</script>

<style lang="scss">

</style>
